<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">


            <div style="margin: 10px 10px 10px 10px">
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <!--<label class="layui-form-label">商品名称</label>-->
                            <div class="layui-input-inline">
                                <input type="text" name="search" autocomplete="off"  placeholder="按【订单编号】搜索" class="layui-input soso" style="width:130%">
                            </div>
                        </div>
                        <div class="layui-inline" style="margin-left: 30px">
                            <button type="submit" class="layui-btn layui-btn-primary" id="formbutton" lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>

                    </div>
                </form>
            </div>



        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="edit">详情</a>
        </script>

    </div>
</div>
{include file="public/footer" /}



<script>
    layui.use(['form', 'table','laydate'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;


        table.render({
            elem: '#currentTableId',
            url: '/admin/member/saleMember?id={$id}&active=ajax',
            method: 'post',
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data, //解析数据列表
                };
            },
            // toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                {field: 'create_time', title: '下单日期'},
                {field: 'order_number', title: '订单编号'},
                {field: 'total_num', title: '商品数量',sort:"true"},
                {field: 'total_price', title: '订单金额',sort:"true"},
                {title: '操作', toolbar: '#currentTableBar', minWidth: 120}
            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line'
        });
        form.on('select(selectInfo)', function (data) {
            $('#formbutton').click();
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: data.field
                }
            }, 'data');

            return false;
        });

        /**
         * toolbar监听事件
         */


        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;

            if (obj.event === 'edit') {
                var index = layer.open({
                    title: '订单详情',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['80%', '80%'],
                    content: '/admin/Member/SaleDetail?id='+data.id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }

        });

    });
</script>

</body>
</html>